# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=physfs
pkgver=3.2.0
pkgrel=1
pkgdesc='Portable and flexible I/O abstraction for archives'
arch=(loong64 x86_64)
url='https://icculus.org/physfs'
license=(ZLIB)
makedepends=(cmake doxygen git ninja)
source=('git+https://github.com/icculus/physfs#commit=eb3383b532c5f74bfeb42ec306ba2cf80eed988c') # tag: release-3.2.0
b2sums=(SKIP)

build() {
  cmake \
    -B build \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D PHYSFS_BUILD_TEST=OFF \
    -G Ninja \
    -S $pkgname
  ninja -C build all docs
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
  install -d "$pkgdir/usr/share/"{doc/physfs,man/man3}
  install -m644 build/docs/html/* "$pkgdir/usr/share/doc/physfs"
  install -m644 build/docs/man/man3/* "$pkgdir/usr/share/man/man3"
  for name in Deinit Free Init Malloc Realloc author deprecated description \
    extension major minor opaque patch remove url; do
    mv "$pkgdir/usr/share/man/man3/"{,PHYSFS_}$name.3
  done
  install -D -m644 $pkgname/LICENSE.txt \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
